#!/bin/sh

echo "Preparing to run tests..."

TDIR=`mktemp -d -t vimium`

if [ $? -ne 0 ]
then
  exit 1
fi

git checkout-index --prefix=$TDIR/ -af
# because submodules don't get picked up by checkout-index
cp -r ./tests/shoulda.js/ $TDIR/tests/shoulda.js/

pushd $TDIR > /dev/null
  cake build && cake test
  TEST_RESULT=$?
popd > /dev/null

echo "Tests completed."

rm -rf $TDIR

exit $TEST_RESULT
